package com.circle.model.module.log;

public class ErrorLogger extends LoggerABC{

    public ErrorLogger(int level) {
        this.level = level;
    }

    @Override
    protected void write(String message) {
        String fileaname = "Log_Error";
        StackTraceElement[] arrayOfStackTraceElement = this.exception.getStackTrace();
        StringBuffer logBuffer = new StringBuffer();
        logBuffer.append(message);
        logBuffer.append("\r\n");
        logBuffer.append("Exception异常信息：" + this.exception.toString()+"\r\nMessage: "+ this.exception.getMessage());
        for (int i = 0; i < arrayOfStackTraceElement.length; i++) {
            StackTraceElement localStackTraceElement = arrayOfStackTraceElement[i];
            logBuffer.append("ClassName: ");
            logBuffer.append(localStackTraceElement.getClassName());
            logBuffer.append(" ; FileName: ");
            logBuffer.append(localStackTraceElement.getFileName());
            logBuffer.append(" ; MethodName: ");
            logBuffer.append(localStackTraceElement.getMethodName());
            logBuffer.append(" ; LineNumber: ");
            logBuffer.append(localStackTraceElement.getLineNumber());
            logBuffer.append("\r\n");
        }
        appendToFile(fileaname,logBuffer.toString());
    }
}
